﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TheVoiceOfSnake
{
    class Writer
    {
        string final;

        public bool SavaParams(IEnumerable<double> list) 
        {
            ConvertParams(list);
            try
            {
                FileStream fs = new FileStream("params.txt", FileMode.Append, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs);
                sw.Write(final);
                sw.Close();
                return true;
            }
            catch (IOException e) 
            {
                Console.WriteLine(e);
                return false;
            }
        }

        public string ConvertParams(IEnumerable<double> list) 
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("-- P A R A M E T R Y --");
            sb.AppendFormat("\t{0}:{1}:{2}\t{3}/{4}/{5}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year);
            sb.AppendLine();
            foreach (var item in list) 
            { 
                sb.AppendFormat("[{0}],\t ",item);
            }
            sb.AppendLine();
            sb.Append("--------------------------------------------------");
            sb.AppendLine();
            sb.AppendLine();
            return sb.ToString();
        }
    }
}
